package com.example.cmtwo.controller;


import com.example.cmtwo.bean.User;
import com.example.cmtwo.service.AdminUserinformationservice;
import com.example.cmtwo.service.AdminUserservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

@Controller
public class AdminUserController {

        @Autowired
        private AdminUserservice adminUserservice;

        private  User user;



        @ResponseBody
        @RequestMapping(value = "/users",method = RequestMethod.GET)
        public Map<Integer,Map> getuserinformation()
        {
            List<User> users = new LinkedList<User>();
            Map<Integer,Map> list = new HashMap<Integer, Map>();
            users = adminUserservice.getUserByall();
            Integer item=0;

            for (Iterator i =users.iterator();i.hasNext();)
            {
                Map<String,String> map = new HashMap<String, String>();
                user =(User) i.next();
                map.put("Uid",user.getUid().toString());
                map.put("UName",user.getUname());
                map.put("UPassword",user.getUpassword());

                list.put(item,map);
                item++;
            }

            return list;
        }
}
